import request from '@/utils/request'
import type { ResSkuList, ResSkuInfo } from './type'

enum API {
  // 获取当页商品
  sku_url = '/admin/product/list/',
  // 商品上架
  cancel_sale_url = '/admin/product/cancelSale/',
  // 商品下架
  on_sale_url = '/admin/product/onSale/',
  // 获取详细商品信息（服务器接口有误，无法使用）
  skuinfo_url = '/admin/product/getSkuById/',
  // 删除商品
  delete_sku_url = '/admin/product/deleteSku/',
}

// 获取当页商品接口
export const reqSkuList = (pager: number, limit: number) =>
  request.get<any, ResSkuList>(API.sku_url + `${pager}/${limit}`)

export const reqCancelSale = (id: number) =>
  request.get<any, any>(API.cancel_sale_url + id)

export const reqOnSale = (id: number) =>
  request.get<any, any>(API.on_sale_url + id)

export const reqSkuInfo = (id: number) =>
  request.get<any, ResSkuInfo>(API.skuinfo_url + id)

export const reqDeleteSku = (id: number) =>
  request.delete<any, any>(API.delete_sku_url + id)
